$def with (username, key=None, owners_page=False, public=False, counts=None, lists=None, component_times={})

  $def year_span(year, use_local_year=False):
    $if use_local_year:
      <span class="use-local-year" data-server-year="$year">$year</span>
    $else:
      <span>$year</span>
  $ component_times['Sidebar'] = time()
  <div class="mybooks-menu">
    $if owners_page:
      <ul class="sidebar-section">
        <li class="section-header">$username</li>
        <li>
          <a class="li-title-desktop" href="/account/loans" data-ol-link-track="MyBooksSidebar|Loans" $('class=selected' if key == 'loans' else '')>$_('My Loans')</a>
        </li>
        <li>
          <a class="li-title-desktop" data-ol-link-track="MyBooksSidebar|LoanHistory" href="/account/loan-history">$_('Loan History')</a>
        </li>
	<li><a data-ol-link-track="MyBooksSidebar|MyFeed" $('class=selected' if key=='feed' else '') href="/people/$username/books/feed">$_('My Feed')</a></li>
      </ul>
    </ul>
    $if owners_page:
      $ year = current_year()
      $ current_goal = get_reading_goals(year=year)
      $ hidden = 'hidden' if current_goal else ''
      <ul class="sidebar-section">
        <li class="section-header">$_("%(year)d Reading Goal", year=year)</li>
        <li>
          <div class="yearly-goal-section">
            <div class="chip-group $hidden">
              <span class="">
                $ year_markup = year_span(year)
                <a class="set-reading-goal-link" data-ol-link-track="MyBooksLandingPage|SetReadingGoal"href="javascript:;">$:_('Set %(year_span)s reading goal', year_span=year_markup)</a>
              </span>
              $ reading_goal_form = render_template('check_ins/reading_goal_form', year=year)
              $:render_template('native_dialog', 'yearly-goal-modal', reading_goal_form, title=_('Yearly Reading Goal'))
            </div>
            $if current_goal:
            <span id="reading-goal-container">
              $:render_template('check_ins/reading_goal_progress', [current_goal])
            </span>
          </div>
        </li>
      </ul>

    $if public or owners_page:
      <ul class="sidebar-section">
        <li class="section-header">$_('Reading Log')</li>
        <li>
          <a class="li-title-desktop" href="/people/$username/books/currently-reading" data-ol-link-track="MyBooksSidebar|CurrentlyReading" $('class=selected' if key == 'currently-reading' else '')><span class="li-count">$counts['currently-reading']</span>$_('Currently Reading')</a>
        </li>
        <li>
          <a class="li-title-desktop" href="/people/$username/books/want-to-read" data-ol-link-track="MyBooksSidebar|WantToRead" $('class=selected' if key == 'want-to-read' else '')><span class="li-count">$counts['want-to-read']</span>$_('Want to Read')</a>
        </li>
        <li>
          <a class="li-title-desktop" href="/people/$username/books/already-read" data-ol-link-track="MyBooksSidebar|AlreadyRead" $('class=selected' if key == 'already-read' else '')><span class="li-count">$counts['already-read']</span>$_('Already Read')</a>
        </li>
      $if owners_page:
        <hr>
	<li><a data-ol-link-track="MyBooksSidebar|MyNotes" $('class=selected' if key=='notes' else '') href="/people/$username/books/notes"><span class="li-count">$counts['notes']</span>$_('My Notes')</a></li>
        <li><a data-ol-link-track="MyBooksSidebar|MyReviews" $('class=selected' if key=='observations' else '') href="/people/$username/books/observations"><span class="li-count">$counts['observations']</span>$_('My Reviews')</a></li>
        <hr>
        <li><a data-ol-link-track="MyBooksSidebar|ReadingStats" href="/account/books/already-read/stats">$_('My Reading Stats')</a></li>
        <li><a data-ol-link-track="MyBooksSidebar|ImportExport" href="/account/import" $('class=selected' if key=='imports' else '')>$_("Import & Export Options")</a></li>
      </ul>
    <ul class="sidebar-section">
      <li class="section-header section-header-split"><span>$(_('My lists') if owners_page else _('Lists'))</span> <a href="/people/$username/lists" data-ol-link-track="MyBooksSidebar|AllLists" class="li-count chevron">$(_('See All'))</a></li>
      $if owners_page:
        <li class="create-new-list">
          <a href="/people/$username/lists/add">$_('Create a list')</a>
        </li>

      <div class="list-overflow">
        $ placeholder_name = _('Untitled list')
        $for lst in lists:
        $# e.g. OL1L from /people/mekBot/lists/OL1L
          $ list_id = lst.key.split('/')[-1]
          $ class_list = ''
          $if key == 'list':
            $# e.g. /people/openlibrary/lists/OL1L/MyList
            $ path_id = ctx.path.split('/')[4]
            $if list_id == path_id:
              $ class_list = class_list + 'selected'
          <li><a class="$class_list" data-ol-link-track="MyBooksSidebar|PatronList" href="/people/$username/lists/$list_id"><span class="li-count">$(len(lst.seeds))</span>$(lst['name'] if lst['name'] else '[%s]' % placeholder_name)</a></li>
      </div>
    </ul>
  </div>
  $ component_times['Sidebar'] = time() - component_times['Sidebar']
